package com.example.windowdemo.window.factory;

import android.content.Context;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.WindowManager;

import com.example.windowdemo.base.WindowBaseFactory;
import com.example.windowdemo.window.Window;
import com.example.windowdemo.window.builder.WindowBuilder;

/**
 * @author: njb
 * @date: 2023/8/3 15:49
 * @desc:
 */
public class CustomWindowFactory extends WindowBaseFactory {
    private int layoutResId;

    public CustomWindowFactory(int layoutResId) {
        this.layoutResId = layoutResId;
    }

    @Override
    public Window createWindow(Context context) {
        WindowBuilder builder = new WindowBuilder(context)
                .setContentView(layoutResId)
                .setGravity(Gravity.CENTER)
                .setFullScreen(false)
                .setSize(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
        return builder.build(context);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        return false;
    }

}
